﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cinemax.DAO;
using Cinemax.DTO;

namespace Cinemax
{
    public partial class Personalize : System.Web.UI.Page
    {
        public List<VeDTO> dsVeDaDat = new List<VeDTO>();
        public List<SuatChieuDTO> dsSuatChieu = new List<SuatChieuDTO>();
        public List<PhimDTO> dsPhim = new List<PhimDTO>();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user_login"] != null)
            {
                string user_login = Session["user_login"].ToString();
                int id = int.Parse(user_login);
                TaiKhoanDTO tk = TaiKhoanDAO.getInfoByID(id);
                if (tk.VaiTro=="QL")
                {
                    update_lv.Visible = true;
                    update_km.Visible = true;
                    insert_sc.Visible = true;
                }
                if (Request.QueryString["drop"] != null)
                {
                    if (Request.QueryString["id"] != null)
                    {
                        int idVeDrop = int.Parse(Request.QueryString["id"].Trim());
                        VeDAO.UnBookTicket(idVeDrop, id);
                    }
                }
                dsVeDaDat = VeDAO.getTicketBookedByID(id);
                foreach (VeDTO item in dsVeDaDat)
                {
                    int IDSuatChieu = item.MaSuatChieu;
                    SuatChieuDTO sc = SuatChieuDAO.getSuatChieuByID(IDSuatChieu);
                    dsSuatChieu.Add(sc);
                }
                foreach (SuatChieuDTO item in dsSuatChieu)
                {
                    int IDMaPhim = item.MaPhim;
                    PhimDTO p = PhimDAO.getPhimByID(IDMaPhim);
                    dsPhim.Add(p);
                }
            }
        }
    }
}